package com.mc.facade;

import java.util.Objects;
//import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import com.mc.service.did.DidService;

/**
 * Did Access entrance method
 */
@RestController
public class DidFacadeImpl{
	
	// Dubbo Rpc Way
//	@DubboService
//	public class DidFacadeImpl implements DidFacade{

	private DidService didService;

	public DidFacadeImpl(DidService didService) {
		this.didService = didService;
	}

	/**
	 * Http Request
	 */
	@GetMapping("/did/{type}")
	public long getDid2(@PathVariable("type")String type) {
		
		if (Objects.isNull(type)) {
			// Default type
			return didService.nextId("dbid");
		}

		return didService.nextId(type);
	}
	
	/**
	 * Dubbo RPC
	 */
//	@Override
	public long getDid(String type) {
		if (Objects.isNull(type)) {
			// Default type
			return didService.nextId("dbid");
		}

		return didService.nextId(type);
	}
}
